package com.budwk.app.util.poiUtils.fireHiddenExcel;

import com.budwk.app.sqfw.dto.FireHiddenExcelParamSQDTO;
import com.budwk.app.sqfw.enums.StreetEnum;
import com.budwk.app.util.poiUtils.fireHiddenExcel.impl.WeiQingMenFireHiddenExcel;
import com.budwk.app.util.poiUtils.fireHiddenExcel.impl.YuHongFireHiddenExcel;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ywm
 * @project wk-mini
 * @description 消防安全工厂
 * @date 2023/11/29 14:34:18
 */
public class FireHiddenExcelFactory {

    private static final Map<String, IFireHiddenExcel> MAP = new HashMap<>();
    static {
        MAP.put(StreetEnum.WEI_QING_MEN_STREET.getName(), new WeiQingMenFireHiddenExcel());
        MAP.put(StreetEnum.YUN_TAN_STREET.getName(), new YuHongFireHiddenExcel());
    }

    /**
     * 生成excel
     * @param excelParamSQDTO
     * @return
     */
    public static String createExcel(FireHiddenExcelParamSQDTO excelParamSQDTO) {
        IFireHiddenExcel fireHiddenExcel = getIFireHiddenExcel(excelParamSQDTO.getCompleteUnitName());
        //返回"null"是便于和null区分
        if (fireHiddenExcel == null) return "null";
        return fireHiddenExcel.createExcel(excelParamSQDTO);
    }

    public static String downExcelTemplate(FireHiddenExcelParamSQDTO excelParamSQDTO) {
        IFireHiddenExcel fireHiddenExcel = getIFireHiddenExcel(excelParamSQDTO.getCompleteUnitName());
        //返回"null"是便于和null区分
        if (fireHiddenExcel == null) return "null";
        return fireHiddenExcel.downExcelTemplate(excelParamSQDTO);
    }

    private static IFireHiddenExcel getIFireHiddenExcel(String unitName) {
        for (String key : MAP.keySet()) {
            if (unitName.contains(key)) {
                return MAP.get(key);
            }
        }
        return null;
    }
}
